
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

firefox_service = FirefoxService(executable_path = "E:/桌面/geckodriver-v0.36.0-win64/geckodriver.exe")
driver = webdriver.Firefox(service = firefox_service)
driver.get("https://www.baidu.com")
time.sleep(1)

# 4. 在搜索框输入 "迪丽热巴"
driver.find_element(By.CSS_SELECTOR, "#chat-textarea").send_keys("劳斯莱斯")
time.sleep(1)

# 5. 点击 "百度一下" 按钮
driver.find_element(By.CSS_SELECTOR, "#chat-submit-button").click()
time.sleep(1)

# 6. 关闭浏览器
driver.quit()